package entertainmentguide.entity;

import java.util.StringTokenizer;
/**   
 *
 * 
 */    
public class User {
    private int userId;
    private String userName;
    private String password;
    private int status;

/* TEST TEST */
  /* TEST TEST */
    /* TEST TEST */
    /* TEST TEST */

    public User(int userId, String userName, String password, int status) {
        this.userId = userId;
        this.userName = userName;
        this.password = password;
        this.status=status;
    }

    public User() {
        
    }

    
    public void setUserId(int userId) {
        this.userId = userId;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserName() {
        return userName;
    }
    
    public void setPassword(String password) {
        this.password=password;
    }

    public String getPassword(){
        return password;
    }
    
    public void setStatus(int status){
        this.status= status;
    }
    
    public int getStatus(){
        return status;
    }
    
    @Override
    public String toString(){
        return  "\n" + " | " + "ID: " + getUserId() + " | " +
                "Όνομα: " + getUserName() + " | ";
    }

    /**                                            ΟΛΕΣ ΟΙ PARSING ΜΕΘΟΔΟΙ ΔΕΝ ΞΕΡΩ ΑΚΟΜΑ ΑΝ ΧΡΕΙΑΖΟΝΤΑΙ - ΤΙΣ ΕΒΑΛΑ ΜΕ ΒΑΣΗ ΠΑΛΙΑ ΕΡΓΑΣΙΑ ΠΟΥ ΤΟ ΕΙΧΕ ΕΤΣΙ
     * Creates a User object by parsing line.
     * The line must be in the following format:
     * CUSTOMER: <userId> <userName>
     *
     * @param line
     * @return
     */
    public static User parseUser(String line) throws IllegalArgumentException{
        StringTokenizer strTok = new StringTokenizer(line);
        String s1 = strTok.nextToken(); // User:
        String s2 = strTok.nextToken(); // userId
        String s3 = strTok.nextToken(); // userName
        String s4 = strTok.nextToken(); // password
        String s5 = strTok.nextToken(); // status
        strTok.nextToken("\""); //Skip the first toker with "

        int d2 = Integer.parseInt(s2);
        int d5 = Integer.parseInt(s5);

        return new User(d2,s3,s4,d5);
    }

}
